package com.ww.netty.basic;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.ww.juc.futureandcallable.GuavaFutureDemo;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.util.ReferenceCountUtil;
import lombok.extern.slf4j.Slf4j;

public class NettyDiscardHandler extends ChannelInboundHandlerAdapter {
	
	private static Logger log = LoggerFactory.getLogger(GuavaFutureDemo.class);

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        ByteBuf in = (ByteBuf) msg;
        try {
            log.info("收到消息，丢弃如下");
            while (in.isReadable()) {
                System.out.println((char) in.readableBytes());
            }
            System.out.println();
        } finally {
            ReferenceCountUtil.release(msg);
        }
    }
}
